using System;
using System.Collections;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;

namespace CSW.Framework.UI.DevEx.Forms
{
    /// <summary>
    /// DXGetDateForm
    /// </summary>
    public sealed partial class DXDropdownForm : XtraForm
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="DXGetDateForm"/> class.
        /// </summary>
        /// <param name="caption">The caption.</param>
        /// <param name="label">The label.</param>
        /// <param name="list">The list.</param>
        /// <param name="defaultValue">The default value.</param>
        public DXDropdownForm(string caption, string label, ICollection list, object defaultValue)
        {
            InitializeComponent();

            Text = caption;
            layoutControlItem1.Text = label;

            comboBoxEdit1.Properties.Items.AddRange(list);
            comboBoxEdit1.SelectedItem = defaultValue;
            comboBoxEdit1.Properties.TextEditStyle = TextEditStyles.DisableTextEditor;
        }

        private void cmdCancel_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
            Close();
        }

        private void cmdOK_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// Gets the selected item.
        /// </summary>
        /// <value>The selected item.</value>
        public object SelectedItem
        {
            get
            {
                return comboBoxEdit1.SelectedItem;
            }
        }
    }
}